Let $M$ be the maximum possible value of $x_1x_2+x_2x_3+\cdots +x_5x_1$ where $x_1, x_2, \dots, x_5$ is a permutation of $(1,2,3,4,5)$ and let $N$ be the number of permutations for which this maximum is attained. Evaluate $M+N$.
Explanation: Arrange the five numbers 1, 2, 3, 4, 5 in a circle, in some order.  We can place the 5 at the top; let the other numbers be $a,$ $b,$ $c,$ $d.$  Then the sum we are interested in is the sum of the product of adjacent pairs.

[asy]
unitsize(1 cm);

label("$5$", dir(90), fontsize(18));
label("$a$", dir(90 - 360/5), fontsize(18));
label("$b$", dir(90 - 2*360/5), fontsize(18));
label("$c$", dir(90 - 3*360/5), fontsize(18));
label("$d$", dir(90 - 4*360/5), fontsize(18));
[/asy]

Assume that the numbers have been arranged so that the sum we are interested in has been maximized.  The sum for this arrangement is $5a + ab + bc + cd + 5d.$  This means that if we were to change the arrangement, the sum must either stay the same or decrease.

Suppose we swap 5 and $a$:

[asy]
unitsize(1 cm);

label("$a$", dir(90), fontsize(18));
label("$5$", dir(90 - 360/5), fontsize(18));
label("$b$", dir(90 - 2*360/5), fontsize(18));
label("$c$", dir(90 - 3*360/5), fontsize(18));
label("$d$", dir(90 - 4*360/5), fontsize(18));
[/asy]

The sum is now $5a + 5b + bc + cd + ad.$  Hence,
\[5a + 5b + bc + cd + ad \le 5a + ab + bc + cd + 5d.\]This reduces to $ab - ad + 5d - 5b \ge 0,$ which factors as $(5 - a)(d - b) \ge 0.$  We know $5 - a \ge 0,$ so $d - b \ge 0.$  And since $b$ and $d$ are distinct, $d > b.$

Now, suppose we swap 5 and $d$:

[asy]
unitsize(1 cm);

label("$d$", dir(90), fontsize(18));
label("$a$", dir(90 - 360/5), fontsize(18));
label("$b$", dir(90 - 2*360/5), fontsize(18));
label("$c$", dir(90 - 3*360/5), fontsize(18));
label("$5$", dir(90 - 4*360/5), fontsize(18));
[/asy]

The sum is now $ad + ab + bc + 5c + 5d.$  Hence,
\[ad + ab + bc + 5c + 5d \le 5a + ab + bc + cd + 5d.\]This reduces to $cd - ad + 5a - 5c \ge 0,$ which factors as $(5 - d)(a - c) \ge 0.$  We know $5 - d \ge 0,$ so $a - c \ge 0.$  And since $a$ and $c$ are distinct, $a > c.$

Finally, by reflecting the diagram along the vertical axis, we can assume that $b > c.$  This leaves three cases to check:
\[
\begin{array}{c|c|c|c|c}
a & b & c & d & 5a + ab + bc + cd + 5d \\ \hline
2 & 3 & 1 & 4 & 43 \\
3 & 2 & 1 & 4 & 47 \\
4 & 2 & 1 & 3 & 48
\end{array}
\]Hence, the largest possible sum is 48.  Furthermore, there are ten permutations that work: The five cyclic permutations of $(5,4,2,1,3),$ and the five cyclic permutations of its reverse, namely $(5,3,1,2,4).$  Thus, $M + N = 48 + 10 = \boxed{58}.$